import React from "react";
import ReactDOM from "react-dom";
import singleSpaReact from "single-spa-react";
import Root from "./root.component";

const lifecycles = singleSpaReact({
  React,
  ReactDOM,
  rootComponent: Root,
  errorBoundary(err, info, props) {
    // Customize the root error boundary for your microfrontend here.
    return null;
  },
})
let subject1 = null
export async function mount(props) {
  console.log(props)
    props.onGlobalStateChange((state, prevState) => {
      console.log('global change', state, prevState)
    }, true)
    setTimeout(() => {
      props.setGlobalState({
        count: 123
      })
      console.log('sdd')
    }, 5000)

  lifecycles.mount(props)
}
export async function unmount(props) {
  if (subject1) {
    console.log('取消订阅')
    props.offGlobalState({
      count: 123
    })

  }
  lifecycles.mount(props)
}
export const {
  bootstrap
} = lifecycles;